//package com.yunhe.common.task;
//
//import com.yunhe.common.service.data.RealtimeService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.Scheduled;
//
//import java.util.*;
//
//@Configuration
//public class XigesiTask {
//
//    @Autowired
//    private RealtimeService realtimeService;
////    @Autowired
////    private RealtimeClient realtimeClient;
//
//    private Long pointNumber = 11109999500111L;
//    private Long dayCharge = 11101000050012L;
//    private Long monthCharge = 11101000050013L;
//    private Long amountCharge = 11101000050015L;
//    private Long dayDischarge = 11101000050017L;
//    private Long monthDischarge = 11101000050018L;
//    private Long amountDischarge = 111010000500110L;
//    private Long dayProfit = 111010000500192L;
//    private Long monthProfit = 111010000500193L;
//    private Long amountProfit = 111010000500195L;
//
//    private Double chargePrice = 0.3111D;
//    private Double dischargePrice = 0.3949D;
//
//    private String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzNDQxNDEiLCJmaXJtSWQiOjQwNTUsInJvbGVJZCI6NDA1NiwiZXhwIjoxNjAxOTAzMzU2LCJ1c2VyTmFtZSI6IndhbmdrYWkiLCJ1c2VySWQiOjM0NDE0MX0.qW7rDRzjR-cVfFzPObcctfXfVWPpDr1sBxuT0_RUjE7ZtPM2zaoqk_jffYigHtPrf_2KTYB_9VJQFaAu5shP3rf7tMHVIcgXoJ55gd8rYfiG_fmifdAVF8WKy4-pO4vhZaw4laWuXomncm6N5DWq2XwxppS7tF0mSxvdyIZqYbLe2MoJ3SfB_AiDxkMSQWKrSf00VmZkTkmvxjhCUMHlihSCaBE91CKI58n1z-2SmRFv9bzJCYkRxrwLJdnIyPp65ZTm3boCc7I7Sk1l1F978_tMQj5li6-Qs-kNiJRdgm4z0zn5tqq3oyv2msJ6dfltccE5-RV4SjPMaz7UbPf5AQ";
//
//    @Scheduled(cron="0/10 * * * * ?")
//    public void task() throws Exception {
//        Date date = new Date();
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(date);
//        int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
//        int hour = calendar.get(Calendar.HOUR_OF_DAY);
//        int minute = calendar.get(Calendar.MINUTE);
//        int second = calendar.get(Calendar.SECOND);
//        boolean flag = hour == 0 && minute == 0 && second < 10;
//        Map<Long, Double> map = realtimeService.findMeasureRealtime(Arrays.asList(pointNumber, dayCharge, monthCharge, amountCharge,
//                dayDischarge, monthDischarge, amountDischarge, dayProfit, monthProfit, amountProfit));
////        Map<Long, Double> map = realtimeClient.get(Arrays.asList(pointNumber, dayCharge, monthCharge, amountCharge,
////                dayDischarge, monthDischarge, amountDischarge, dayProfit, monthProfit, amountProfit), token).getResults();
//        Double value = map.get(pointNumber);
//        Map<Long, Double> values = new HashMap<>();
//        //电量
//        double val = Math.abs(value) * 10 / 3600;
//        double profit = 0D;
//        if (value > 0) {
//            //放电
//            double day = map.get(dayDischarge) + val;
//            values.put(dayDischarge, day);
//            double month = map.get(monthDischarge) + val;
//            values.put(monthDischarge, month);
//            double amount = map.get(amountDischarge) + val;
//            values.put(amountDischarge, amount);
//            profit = val * dischargePrice;
//        } else if (value < 0) {
//            //充电
//            double day = map.get(dayCharge) + val;
//            values.put(dayCharge, day);
//            double month = map.get(monthCharge) + val;
//            values.put(monthCharge, month);
//            double amount = map.get(amountCharge) + val;
//            values.put(amountCharge, amount);
//            profit = - val * chargePrice;
//        }
//        Double dp = map.get(dayProfit);
//        values.put(dayProfit, dp + profit);
//        Double mp = map.get(monthProfit);
//        values.put(monthProfit, mp + profit);
//        Double ap = map.get(amountProfit);
//        values.put(amountProfit, ap + profit);
//        realtimeService.saveMeasureRealtime(values);
////        realtimeClient.post(values, token);
//        if (flag) {
//            Map<Long, Double> valueMap = new HashMap<>();
//            valueMap.put(dayCharge, 0D);
//            valueMap.put(dayDischarge, 0D);
//            valueMap.put(dayProfit, 0D);
//            if (dayOfMonth == 1) {
//                valueMap.put(monthCharge, 0D);
//                valueMap.put(monthDischarge, 0D);
//                valueMap.put(monthProfit, 0D);
//            }
////            valueMap.put(11101000050013L, 660D);
////            valueMap.put(11101000050018L, 680D);
////            valueMap.put(111010000500193L, 55.308D);
////            valueMap.put(11101000050015L, 660D);
////            valueMap.put(111010000500110L, 680D);
////            valueMap.put(111010000500195L, 55.308D);
//            realtimeService.saveMeasureRealtime(valueMap);
//        }
//    }
//}
